﻿using Gp.Scripts.Core;
using Helpers;
using QFramework;
using UnityEngine;

namespace Gp.Scripts.Core
{
    public class PropModel : UnitModel
    {
        protected override void Awake()
        {
            base.Awake();
            this.GetOrAddComponent<Animator>();
        }


        protected override void OnInit()
        {
            UnitReference.RegisterEvent<Event_Unit.Highlight>(OnUnitHighlight);
            UnitReference.RegisterEvent<Event_Unit.DeHighlight>(OnUnitDeHighlight);
        }
        
        
        private void OnUnitDeHighlight(Event_Unit.DeHighlight obj) {
            this.UnitReference.DisableHighlightEffect();
        }

        private void OnUnitHighlight(Event_Unit.Highlight obj) {
            this.UnitReference.TriggerHighlightEffect();

            // if (this.TryGetComponent<Highlighter>(out var c)) {
            //     c.Settings.OuterGlowColorFront = UnitReference.PlayerNumber == PlayerConst.PlayerUnitNumber
            //         ? Color.green
            //         : Color.red;
            // }
        }
    }
}